package com.flyduck.mall.pms.admin.controller;

import com.flyduck.mall.pms.admin.service.AdminSkuService;
import com.flyduck.ss.common.core.domain.R;
import com.flyduck.mall.common.web.core.BaseController;
import com.flyduck.mall.pms.admin.vo.AdminSkuDetailsRespVO;
import com.flyduck.mall.pms.admin.vo.AdminSkuSaveReqVO;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * AdminSkuController
 * </p>
 *
 * @author flyduck
 * @since 2024-06-06
 */
@RestController
@RequestMapping("/admin/sku")
public class AdminSkuController extends BaseController {

    @Resource
    private AdminSkuService adminSkuService;

    @GetMapping("/getSkuDetailsByProductId/{productId}")
    public R<AdminSkuDetailsRespVO> getSkuDetailsByProductId(@PathVariable("productId") Long productId){
        AdminSkuDetailsRespVO adminSkuDetailsRespVO = adminSkuService.getSkuDetailsByProductId(productId);
        return R.ok(adminSkuDetailsRespVO);
    }

    @PostMapping("/saveSku")
    public R<Void> saveSku(@Validated @RequestBody AdminSkuSaveReqVO adminSkuSaveReqVO){
        adminSkuService.saveSku(adminSkuSaveReqVO);
        return R.ok();
    }
}

